import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
import validateTags from './scripts/validate-tags';
import * as sass from 'sass-embedded';

export default defineConfig({
  plugins: [vue({
    template: {
      compilerOptions: {
        nodeTransforms: [validateTags]
      }
    }
  })],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        implementation: sass,
        silenceDeprecations: ['legacy-js-api']
      }
    }
  },
  server: {
  //用热模块替换
    proxy: {
      // 代理配置
      '/api': {
        target: 'http://localhost:8080/usersystem', // 目标服务器
        changeOrigin: true, // 改变源
        rewrite: (path) => path.replace(/^\/api/, '') // 重写路径
      }
    }
  }
})
        